<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">

<ui:composition template="/pages/layout/mainLayout.xhtml">
	<ui:define name="bodyComUsuario">
		<div class="post">
		<h2 class="title"><h:outputLabel
			value="#{bundle['locanet.locacoes.buscaLocacoes']}" /></h2>
		<h:form>
			<h:panelGrid columns="2">
				<h:outputLabel value="#{bundle['locanet.locacoes.codigoCopia']}" />
				<h:inputText value="#{locacaoBean.entity.filme.id}" />
				<h:outputLabel value="#{bundle['locanet.tipo.cliente']}"
					rendered="#{loginBean.funcionario}" />
				<h:selectOneMenu value="#{locacaoBean.id_cliente}"
					rendered="#{loginBean.funcionario}">
					<f:selectItem itemValue="" itemLabel="" />
					<f:selectItems value="#{locacaoBean.listaClientes}" var="cliente"
						itemValue="#{cliente.id}" itemLabel="#{cliente.nome}" />
				</h:selectOneMenu>
				<h:outputLabel value="#{bundle['locanet.status']}" />
				<h:selectOneRadio value="#{locacaoBean.entity.statusPagamento}">
					<f:selectItem itemValue="1"
						itemLabel="#{bundle['locanet.entidades.status.devolvido']}" />
					<f:selectItem itemValue="0"
						itemLabel="#{bundle['locanet.entidades.status.pendente']}" />
				</h:selectOneRadio>
				<h:commandButton action="#{locacaoBean.search}"
					value="#{bundle['locanet.butoes.buscar']}" />
				<h:outputText />
			</h:panelGrid>
		</h:form></div>
		<div class="post"><h:form>
			<p:dataTable value="#{locacaoBean.entities}" var="loca">
				<p:column rendered="#{loginBean.funcionario}">
					<f:facet name="header">
						<h:outputText value="#{bundle['locanet.tipo.cliente']}" />
					</f:facet>
					<h:outputText value="#{loca.cliente.nome}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="#{bundle['locanet.tipo.funcionario']}" />
					</f:facet>
					<h:outputText value="#{loca.funcionario.nome}"
						rendered="#{!empty loca.funcionario.nome}" />
					<h:outputText style="font-weight: bold;font-style: italic" value="Internet" rendered="#{empty loca.funcionario.nome}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="#{bundle['locanet.Filme.filme']}" />
					</f:facet>
					<h:commandLink value="#{loca.filme.codigo} - #{loca.filme.filme.titulo}"
						action="#{filmeBean.view}">
						<f:setPropertyActionListener value="#{loca.filme.filme.id}"
							target="#{filmeBean.entity.id}" />
					</h:commandLink>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="#{bundle['locanet.locacoes.locacao']}" />
					</f:facet>
					<h:outputText value="#{loca.dataLocacao}">
						<f:convertDateTime pattern="dd/MM/yyyy" />
					</h:outputText>
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="#{bundle['locanet.locacoes.devolucao']}" />
					</f:facet>
					<h:outputText style="color:green" value="#{loca.dataDevolucao}"
						rendered="#{loca.statusPagamento==1}">
						<f:convertDateTime pattern="dd/MM/yyyy" />
					</h:outputText>
					<h:outputText style="color: red"
						rendered="#{loca.statusPagamento==0 and loginBean.cliente}"
						value="#{bundle['locanet.entidades.status.pendente']}" />
					<h:commandLink rendered="#{loca.statusPagamento==0 and loginBean.funcionario}" value="#{bundle['locanet.locacoes.mudarDevolucao']}"
						action="#{locacaoBean.finalizaLocacao}">
						<f:setPropertyActionListener value="#{loca.id}"
							target="#{locacaoBean.entity.id}" />
					</h:commandLink>
				</p:column>
			</p:dataTable>
		</h:form></div>
	</ui:define>
</ui:composition>
</html>
